package service.impl;

import dao.PatientDoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.PatientDoctor;
import service.PatientDoctorService;

import java.util.List;

@Service
public class PatientDoctorServiceImpl implements PatientDoctorService {

    @Autowired
    private PatientDoctorMapper patientDoctorMapper;

    @Override
    public List<PatientDoctor> findAll() {
        return patientDoctorMapper.findAll();
    }

    @Override
    public int add(PatientDoctor patientDoctor) {
        return patientDoctorMapper.addPatientDoctor(patientDoctor);
    }

    @Override
    public int update(PatientDoctor patientDoctor) {
        return patientDoctorMapper.updatePatientDoctor(patientDoctor);
    }

    @Override
    public int deletePatientDoctor(Integer id) {
        return patientDoctorMapper.deletePatientDoctor(id);
    }

    @Override
    public PatientDoctor findById(Integer id) {
        return patientDoctorMapper.findById(id);
    }

    /**
     * 根据医生ID查询患者-医生关联数据
     * @param docId 医生ID
     * @return 该医生的所有患者关联记录列表
     */
    @Override
    public List<PatientDoctor> findByDocId(String docId) {
        return patientDoctorMapper.findByDocId(docId);
    }
}